<script type="text/javascript">
    $(document).ready(function() {
        $("#activity_checkAll").click(function() {
            if ($(this).attr("checked") == "checked") {
                $(":checkbox").attr("checked", true);
            } else {
                $(":checkbox").attr("checked", false);
            }
        });

    });
</script> 
<fieldset>
    <table class="table table-hover">
        <thead>
            <tr>
                <th><input type="checkbox" name="activity_checkAll" id="activity_checkAll"></th>
                <th>添加方式</th>
                <th>申请人资格</th>
                <th>截止时间</th>
                <th>操作</th>
            </tr> 
        </thead>
        <tbody>
            <?php
            foreach ($permitView as $id => $list) {
                $roleAlias = '--';
                $permitAlias = '--';
                $expireTimeAlias = '--';
                $timestamp = strtotime('+10 years');
                if ($list->getItem('roleId') != NULL) {
                    $roleId = $list->getItem('roleId')->getValue();
                    $role = new BRole($roleId);
                    $roleAlias = BARoleCooker::getRoleAliasByFullName($role->getFullName());
                }
                if ($list->getItem('permit') != NULL) {
                    $permit = $list->getItem('permit')->getValue();
                    $permitAlias = BAMemberCardCooker::getPermitAlias($permit);
                }
                if ($list->getItem('expireTime') != NULL) {
                    $expireTime = $list->getItem('expireTime')->getValue();
                    if ($expireTime > $timestamp) {
                        $expireTimeAlias = '一直有效';
                    } else {
                        $expireTimeAlias = date('Y-m-d:H', $expireTime);
                    }
                }
                ?>
                <tr>
                    <td><label class="checkbox">
                            <input type="checkbox" name="subBox[]" value="<?php echo $id; ?>"> 
                        </label></td>
                    <td> <?php echo $permitAlias; ?> </td>
                    <td> <?php echo $roleAlias; ?> </td>
                    <td> <?php echo $expireTimeAlias; ?> </td>
                    <td>
                        <div class="row-fluid">
                            <?php
                            echo $control->getAjaxLink(array('name' => '设置', 'id' => 'addApplyPermit'), array(
                                'cooker' => 'BAMemberCard@showAddApplyPermit',
                                'permitId' => $id,
                            ));
                            echo ' | ';
                            echo $control->getAjaxLink(array('name' => '删除', 'id' => 'DelApplyPermit'), array(
                                'cooker' => 'BAMemberCard@delApplyPermit',
                                'permitId' => $id,
                            ));
                            ?>
                        </div>                   
                    </td>
                </tr>
            <?php }
            ?>
        </tbody>
    </table>

    <div class="pagination">  
        <ul>  
            <li class="active">
                <a href="javascript:void()">前一页</a>    </li>  
            <li class="active">
                <a href="javascript:void()">1</a>    </li>  
            <li class="active">
                <a href="javascript:void()">后一页</a>    </li>  
        </ul>  
    </div>
    <div class="row-fluid span3 pull-right">
        <?php
        echo $control->getAjaxLink(array('name' => '添加申请设置', 'id' => 'ShowAddApplyPermit'), array(
            'cooker' => 'BAMemberCard@showAddApplyPermit',
            'htmlOptions' => array('class' => 'btn btn-info'),
        ));
        ?>
    </div>
